﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HRM.Models;

namespace HRM.Controllers
{
    public class DanhMuc_tk_HDHocThuatController : Controller
    {
        private HRMTTNS41Context db = new HRMTTNS41Context();

        //
        // GET: /DanhMuc_tk_HDHocThuat/

        public ActionResult Index()
        {
            return View(db.dm_tk_HDHocThuat.ToList());
        }

        //
        // GET: /DanhMuc_tk_HDHocThuat/Details/5

        public ActionResult Details(int id = 0)
        {
            dm_tk_HDHocThuat dm_tk_hdhocthuat = db.dm_tk_HDHocThuat.Find(id);
            if (dm_tk_hdhocthuat == null)
            {
                return HttpNotFound();
            }
            return View(dm_tk_hdhocthuat);
        }

        //
        // GET: /DanhMuc_tk_HDHocThuat/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /DanhMuc_tk_HDHocThuat/Create

        [HttpPost]
        public ActionResult Create(dm_tk_HDHocThuat dm_tk_hdhocthuat)
        {
            if (ModelState.IsValid)
            {
                db.dm_tk_HDHocThuat.Add(dm_tk_hdhocthuat);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(dm_tk_hdhocthuat);
        }

        //
        // GET: /DanhMuc_tk_HDHocThuat/Edit/5

        public ActionResult Edit(int id = 0)
        {
            dm_tk_HDHocThuat dm_tk_hdhocthuat = db.dm_tk_HDHocThuat.Find(id);
            if (dm_tk_hdhocthuat == null)
            {
                return HttpNotFound();
            }
            return View(dm_tk_hdhocthuat);
        }

        //
        // POST: /DanhMuc_tk_HDHocThuat/Edit/5

        [HttpPost]
        public ActionResult Edit(dm_tk_HDHocThuat dm_tk_hdhocthuat)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dm_tk_hdhocthuat).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(dm_tk_hdhocthuat);
        }

        //
        // GET: /DanhMuc_tk_HDHocThuat/Delete/5

        public ActionResult Delete(int id = 0)
        {
            dm_tk_HDHocThuat dm_tk_hdhocthuat = db.dm_tk_HDHocThuat.Find(id);
            if (dm_tk_hdhocthuat == null)
            {
                return HttpNotFound();
            }
            return View(dm_tk_hdhocthuat);
        }

        //
        // POST: /DanhMuc_tk_HDHocThuat/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                dm_tk_HDHocThuat dm_tk_hdhocthuat = db.dm_tk_HDHocThuat.Find(id);
                db.dm_tk_HDHocThuat.Remove(dm_tk_hdhocthuat);
                db.SaveChanges();
            }
            catch {
                TempData["AlertMessage"] = "my alert message";
            }
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}